/**
 */

(function(jQuery) {
	jQuery.fn.onmark = function(options) {
		var defaultOpt = { 
			checkboxCls:'ez-checkbox' , 
			radioCls :'ez-radio' ,	
			checkedCls:'ez-checked'  , 
			selectedCls :'ez-selected' , 
			hideCls   :'ez-hide'
	    };
	    var copt = jQuery.extend(defaultOpt, options);
		return this.each(function() {
			var that = jQuery(this);
			var wrapTag = that.attr('type') == 'checkbox' ? '<div class="' + copt.checkboxCls + '">': '<div class="' + copt.radioCls + '">';
			if (that.attr('type') == 'checkbox') {
				that.addClass(copt.hideCls).wrap(wrapTag).change(function() {
					if (jQuery(this).is(':checked')) {
						jQuery(this).parent().addClass(copt.checkedCls);
					}
					 else {
						jQuery(this).parent().removeClass(copt.checkedCls);
					}
				});
				if (that.is(':checked')) {
					that.parent().addClass(copt.checkedCls);
				}
			}
			 else if (that.attr('type') == 'radio') {
				that.addClass(copt.hideCls).wrap(wrapTag).change(function() {
					jQuery('input[name="' + jQuery(this).attr('name') + '"]').each(function() {
						if (jQuery(this).is(':checked')) {
							jQuery(this).parent().addClass(copt.selectedCls);
						} else {
							jQuery(this).parent().removeClass(copt.selectedCls);
						}
					});
				});
				if (that.is(':checked')) {
					that.parent().addClass(copt.selectedCls);
				}
				if (that.attr('disabled') == 'true') {
					that.parent().addClass(copt.selectedDis);
				}
			}
		});
	}
})(jQuery);